home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_2
/
read.ir
< prev
next >
Wrap
Text File
|
1991-04-12
|
3KB
|
158 lines
Article 2701 of comp.sys.handhelds:
Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!uunet!snorkelwacker.mit.edu!apple!agate!shelby!msi.umn.edu!noc.MR.NET!gacvx2.gac.edu!hhdist
From: erikmb@cd.chalmers.se (Erik Bryntse)
Newsgroups: comp.sys.handhelds
Subject: Test program that reads the IR input of HP48
Message-ID: <9012031147.AA04665@cd.chalmers.se>
Date: 3 Dec 90 11:46:55 GMT
Lines: 142
To: handhelds@gac.edu
Return-path: <erikmb@cd.chalmers.se>
To: handhelds@gac.edu
X-Mailer: ELM [version 2.3 PL8]
Hello!
Since there are many people that are interested in having their 48's
as learning remote controls, I am posting a little test program I
wrote some weeks ago.
It reads the IR input diode, and times each period (at the low-high
transition). The result is returned as a string.
This is only intended to help if someone out there is struggling to
make a remote control program for the 48, so I only include the source
code. It is not very well commented (remember it's a test program...).
Hope this helps someone!
Erik Bryntse
erikmb@cd.chalmers.se
; ---- source code begins here ----
SaveR:=#679B
LoadR:=#67D2
DispOff:=#1BBD
DispOn:=#1B8F
; Test program that reads the IR-diode
; Written by Erik Bryntse
; Returns 1: "string" that contains 3 nibbles per period time
; Parts taken from INPRT by William C Wickes
call.a SaveR ; save RPL regs
call.a #613E
clrb 15,ST
call.a #6806 ; space bw RSTK & TOS -> C
move.a c,a
move.p5 #10F,c
subn.a a,c ; C := space - #200
brcs OutOfMem ; If not enough exit
move.w c,r1 ; Save away in R1
call.a #1115 ; toggles b 0 of #10E
intoff
call.a DispOff
move.w r1,c ; Alloc all mem - #200 nibs
srb.a c ; in bytes!
call.a #5B79 ; alloc C bytes string -> D0
move.w r1,c
swap.a a,d0
move.a a,d0
add.a c,a
move.w a,r1 ; R1 highest allowed addr
clr.w c
move.w c,r4 ; R4 := 0
move.1 4,p
move.p1 #6,c ; C := #60000
move.1 0,p
brcc Begin ; If alloc OK start prog
OutOfMem:
call.a #10E5
jump.a #65AA ; load regs, Out Of Mem!
; Not out of memory error
Begin: call.3 MainProc
call.a #16671
move.5 #10B,d1
move.b @d1,c
clrb #5,c
move.b c,@d1 ; clrb 5 of #10B
call.a DispOn
call.a #10E5
move.w r0,a
call.a #54266
move.a @d0,a
add.a 5,d0
jump @a ; bye bye
;========================================================
MainProc:
call.3 Wait1st ; Wait until IR toggle or timeout
retcs ; Timeout: return
OneMor:
move.x a,@d0 ; Store period time in string (3 nibs)
add.a 3,d0
swap.a a,d0
move.a a,d0
move.a r1,c
retle.a c,a
clr.a a
call.3 WaitL ; Time one more pulse
brcc OneMor
retclrc ; Timeout
; Wait until first IR pulse is received
Wait1st:
clr.w a
move.p5 #20000,c ; Timeout counter
move.5 #0011A,d1
NoIR: dec.a c
brcs TimeOut
move.s @d1,c
add.s c,c
brcc NoIR ; Wait until first IR pulse recvd
; Wait until IR goes low
WaitL: inc.x a
retcs
move.s @d1,c
add.s c,c
brcs WaitL ; Wait until bit 3 of 11A low
; Wait until IR goes high again
WaitH: inc.x a
retcs
move.s @d1,c
add.s c,c
brcc WaitH ; Wait until bit 3 of 11A high
retclrc
TimeOut:
pop.a c
retsetc
; ---- souce code ends here ----